﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dhgms.TplHelper.Controller.Task.Sql
{
    using System.Data.Common;

    using Dhgms.DataManager.Model.Helper.Database;
    using Dhgms.TplHelper.Model.Info.TaskResult;

    /// <summary>
    /// Base Task for calling a SQL stored procedure that returns a result.
    /// </summary>
    /// <typeparam name="TDatabaseHelperClass"></typeparam>
    /// <typeparam name="TInformationClass"></typeparam>
    /// <typeparam name="TParameterClass"></typeparam>
    /// <typeparam name="TAdoNetHelperClass"></typeparam>
    public abstract class StoredProcedure<TDatabaseHelperClass, TInformationClass, TParameterClass, TAdoNetHelperClass> :
        Base<SingleStronglyTyped<TInformationClass>, TDatabaseHelperClass, TParameterClass>
        where TDatabaseHelperClass : DatabaseHelperBase<TParameterClass>, new()
        where TInformationClass : DataManager.Model.Info.Base<TInformationClass>, new()
        where TParameterClass : DbParameter
        where TAdoNetHelperClass : DataManager.Model.Helper.AdoNet.Base<TInformationClass>, new()
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="NonQuery{TDatabaseHelperClass,TParameterClass}"/> class. 
        /// </summary>
        /// <param name="taskName">
        /// The name of the task
        /// </param>
        /// <param name="connectionString">
        /// Database Connection String
        /// </param>
        protected StoredProcedure(string taskName, string connectionString)
            : base(taskName, connectionString)
        {
        }

        #endregion

        #region Methods

        /// <summary>
        /// The OnProcess event for doing the donkey work
        /// </summary>
        /// <param name="result">
        /// The result.
        /// </param>
        protected override void OnProcess(SingleStronglyTyped<TInformationClass> result)
        {
            //var result = this.ProcessStoredProcedure(this.ConnectionString, this.GetStoredProcedureName(), this.GetParameters(), false);
            //this.OnHandleProcedureResult();
        }

        /// <summary>
        /// Event for handling the result from a stored procedure call.
        /// </summary>
        protected abstract void OnHandleProcedureResult();

        #endregion
    }
}
